package com.inno.subject.domain.strategy.subject;

import com.inno.subject.domain.strategy.ai.InterviewMockHandler;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author shenzeyang
 */
@Component
public class SubjectHandlerFactory implements InitializingBean {
    @Resource
    private List<SubjectHandler> subjectHandlerList;
    // 还需要一个map
    private final Map<Long, SubjectHandler> subjectHandlerMap = new HashMap<>();

    public SubjectHandler getSubjectHandler(Long type) {
        return subjectHandlerMap.get(type);
    }
    @Override
    public void afterPropertiesSet() throws Exception {
        subjectHandlerList.forEach(handler -> subjectHandlerMap.put(handler.getTypeId(), handler));
    }
}
